var app = angular.module('myApp', []);
app.controller('PlayerController', ['$scope', function($scope) {
	$scope.playing = false;
	$scope.audio = document.createElement('audio');
	$scope.audio.src = '/media/npr.mp4';
	$scope.play = function() {
	    $scope.audio.play();
	    $scope.playing = true;
	  };
	  $scope.stop = function() {
	    $scope.audio.pause();
	    $scope.playing = false;
	  };
	  $scope.audio.addEventListener('ended', function() {
	    $scope.$apply(function() {
	      $scope.stop()
	    });
	  });
}]);
app.controller('DemoController', function($scope) {
	  $scope.counter = 0;
	  $scope.add = function(amount) { $scope.counter += amount; };
	  $scope.subtract = function(amount) { $scope.counter -= amount; };
	});
//视频
var apiKey = "MDE5ODM4NTI0MDE0MzY1MTk5ODlmNTVhYQ001";
var nprUrl = 'http://api.npr.org/query?id=61&fields=relatedLink,title,byline,text,audio,image,pullQuote,all&output=JSON';
app.controller('PlayerController2', function($scope, $http) {
	$http({
		method: 'JSONP',
		url: nprUrl + '&apiKey=' + apiKey + '&callback=JSON_CALLBACK'
	}).success(function(data, status) {
		$scope.programs = data.list.story;
	}).error(function(data, status) {
	});
});
